<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('划拨记录详情')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <input type="hidden" name="serial" th:value="${serial}" id="serial">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>SN：</label>
                                <input type="text" name="machineNum"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <!--<div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="downloada()" shiro:hasPermission="terminal:record:downloada">
                    <i class="fa fa-plus"></i> 机具划拨模板下载
                </a>
                <a class="btn btn-success" onclick="$.operate.add(800,1100)" shiro:hasPermission="terminal:record:add">
                    <i class="fa fa-plus"></i> 划拨
                </a>
                <a class="btn btn-success" onclick="revoke()" shiro:hasPermission="terminal:record:revoke">
                    <i class="fa fa-plus"></i> 撤机
                </a>
            </div>-->
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('terminal:record:edit')}]];
        var removeFlag = [[${@permission.hasPermi('terminal:record:remove')}]];
        var terminalTypeDatas = [[${@dict.getType('terminal_type')}]];
        var prefix = ctx + "system/detail";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                queryParams:queryParams,
                modalName: "终端划拨记录详情",
                columns: [
                {
                    field: 'serial',
                    title: '批次号',
                    formatter:function (value, row, index) {
                        return $.table.tooltip(value,25);
                    }
                },
                {
                    field: 'machineNum',
                    title: '终端编号'
                },
                    {
                        field: 'simFee',
                        title: '流量卡费'
                    }
                    ,{
                        field: 'posType',
                        title: '终端类型',
                        formatter: function (value, row, index) {
                            return $.table.selectDictLabel(terminalTypeDatas, value);
                        }
                    }
                    ,{
                        field: 'flowAgentNum',
                        title: '流量卡费返现对象',
                        formatter: function (value, row, index) {
                            return row.flowAgentNum;
                        },
                    },{
                        field: 'actAgentNum',
                        title: '达标返现对象',
                        formatter: function (value, row, index) {
                            return row.actAgentNum;
                        },
                    }, {
                        field: 'reachAgentNum',
                        title: '激活返现对象',
                        formatter: function (value, row, index) {
                            return row.reachAgentNum;
                        }
                    },
                ]
            };
            $.table.init(options);
        });

        /**
         * 设置查询参数
         */
        function queryParams(params) {
            var search = $.table.queryParams(params);
            search.serial = $("#serial").val();
            return search;
        }

        function revoke() {
            var url =prefix+ "/revoke";
            $.modal.open("终端撤机" , url, '1200','800');
        }

        function downloada() {
            table.set();
            $.get(prefix+"/exportFile", function(result) {
                if (result.code == web_status.SUCCESS) {
                    window.location.href = ctx + "common/download?fileName=" + encodeURI(result.msg) + "&delete=" + true;
                } else if (result.code == web_status.WARNING) {
                    $.modal.alertWarning(result.msg)
                } else {
                    $.modal.alertError(result.msg);
                }
            });
        }

        /**
         * 查看当前划拨批次机器详情
         * @param serial
         */
        function queryDetails(serial) {
            $.modal.openTab("批次详情", prefix + "/jobList?configKey="+configKey);
        }

    </script>
</body>
</html>
